<template>
	<view class="content" :style="{'height':windowHeight+'px'}">
		<text class="title">正式课</text>
		<uni-list style="width: 750rpx;margin-bottom: 30rpx;">
			<!-- to是超链接地址 -->
			<uni-list-item v-for="(item,index) in classList" @click="toClassInfo(item.classId)" :key="index" :title="item.className" :note="'上课校区：'+item.schoolName" :clickable="true"></uni-list-item>
		</uni-list>
		<button style="width: 700rpx;" @click="endLogin" class="button-green">退出登录</button>
	</view>
</template>

<script>
	import {
		getClassByTeacherId
	} from "../../../api/classTeacher.js"

	export default {
		data() {
			return {
				windowHeight: 0,
				teacherId: null,
				classList: []
			}
		},
		onLoad() {
			let _this = this;
			// 获取页面高度
			_this.$uniApi.getWindowHeight(_this);
			this.getTeacherInfo();
			this.getClassList();
		},
		methods: {
			endLogin() {
				uni.clearStorage();
				uni.navigateTo({
					url: '../teacherLogin'
				})
			},
			toClassInfo(classId){
				uni.navigateTo({
					url:"./classInfo?classId="+classId
				})
			},
			getClassList() {
				getClassByTeacherId(this.teacherId).then(res => {
					console.log(res);
					this.classList = res.data;

				})
			},
			getTeacherInfo() {
				uni.getStorage({
					key: "teacherInfo",
					success: (res) => {
						this.teacherId = res.data.userId;
					}
				})
			}
		}
	}
</script>

<style>
	.content {
		width: 750rpx;
		background-color: #EEEEEE;
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.title {
		display: inline-block;
		width: 750rpx;
		color: #808080;
		font-size: 14px;
		line-height: 35px;
		padding-top: 5rpx;
		padding-left: 30rpx;
	}
</style>
